﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net.Sockets;

namespace QuanLyNhanVien
{
    public partial class frmGiaoDienChinh : Form
    {
        //public Socket sckClient;
        public frmDangNhap frmDangNhap;
        public frmHoSoNhanVien frmHoSoNhanVien;

        public frmGiaoDienChinh()
        {
            InitializeComponent();
            loadGiaoDienDangNhap();
        }

 
       private void đăngXuấtToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Logout ở đây
            MessageBox.Show("Hiện thực đăng xuất ở đây");
        }

        private void đăngNhậpToolStripMenuItem_Click(object sender, EventArgs e)
        {
            loadGiaoDienDangNhap();
        }

        public void LinkLable_AddInfo(Boolean bValue,string strInfo)
        {

/*            if (llbThongTinMoi.InvokeRequired)
            {
                llbThongTinMoi.BeginInvoke(
                new MethodInvoker(
                delegate() { LinkLable_AddInfo(bValue,strInfo); }
                                 )
                                    );
            }
            else
            {
                lock (llbThongTinMoi)
                {
                    llbThongTinMoi.Visible = true;
                    llbThongTinMoi.Text = strInfo;
                }
            }**/
        }


        private void panel_AddForm(frmDangNhap aForm)
        {

            if (pnlChinh.InvokeRequired)
            {
                pnlChinh.BeginInvoke(
                new MethodInvoker(
                delegate() { panel_AddForm(aForm); }
                                 )
                                    );
            }
            else
            {
                lock (pnlChinh)
                {
                    pnlChinh.Controls.Add(aForm);
                    aForm.Show();
                }
            }
        }

        private void panel_ClearForm()
        {

            if (pnlChinh.InvokeRequired)
            {
                pnlChinh.BeginInvoke(
                new MethodInvoker(
                delegate() { panel_ClearForm(); }
                                 )
                                    );
            }
            else
            {
                lock (pnlChinh)
                {
                    pnlChinh.Controls.Clear();
                }
            }
        }

        public void loadGiaoDienDangNhap()
        {
            panel_ClearForm();
            //pnlChinh.Controls.Clear();
            frmDangNhap = new frmDangNhap(this.menuStrip1, this.pnlChinh, this);
            frmDangNhap.TopLevel = false;
            frmDangNhap.FormBorderStyle = FormBorderStyle.None;
            frmDangNhap.Dock = DockStyle.Fill;
            //pnlChinh.Controls.Add(frmDangNhap);
            panel_AddForm(frmDangNhap);
            LinkLable_AddInfo(true, "");
            //frmDangNhap.Show();
           // form_Show(frmDangNhap);
        }

        private void frmGiaoDienChinh_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.Dispose(); 
        }
        private void loadGiaoDienDanhSachDonHang()
        {
            /*
            pnlChinh.Controls.Clear();
            frmDanhSachDonHang frmDanhSachDonHang = new frmDanhSachDonHang();
            frmDanhSachDonHang.TopLevel = false;
            frmDanhSachDonHang.FormBorderStyle = FormBorderStyle.None;
            frmDanhSachDonHang.Dock = DockStyle.Fill;
            pnlChinh.Controls.Add(frmDanhSachDonHang);
            frmDanhSachDonHang.Show();
             * */
        }

        private void loadGiaoHoSoNhanVien()
        {
            pnlChinh.Controls.Clear();
            frmHoSoNhanVien frmHoSoNhanVien = new frmHoSoNhanVien();
            frmHoSoNhanVien.TopLevel = false;
            frmHoSoNhanVien.FormBorderStyle = FormBorderStyle.None;
            frmHoSoNhanVien.Dock = DockStyle.Fill;
            pnlChinh.Controls.Add(frmHoSoNhanVien);
            frmHoSoNhanVien.Show();            
        }
       

        /*private void loadGiaoDienTimKiemNhanVien()
        {
            pnlChinh.Controls.Clear();
            frmTimKiemNhanVien frmTimKiemNhanVien = new frmTimKiemNhanVien();
            frmTimKiemNhanVien.TopLevel = false;
            frmTimKiemNhanVien.FormBorderStyle = FormBorderStyle.None;
            frmTimKiemNhanVien.Dock = DockStyle.Fill;
            pnlChinh.Controls.Add(frmTimKiemNhanVien);
            frmTimKiemNhanVien.Show();
        }*/
        private void pnlChinh_Paint(object sender, PaintEventArgs e)
        {

        }

        public void checkUserGrant()
        {

        }

        private void thoátToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void Menu_HuongDanSuDung_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Thông tin về nhóm phát triển phần mềm");
        }

        private void Menu_ThongTinPhanMem_Click(object sender, EventArgs e)
        {
            loadGiaoHoSoNhanVien();            
        }

        private void Menu_HeThong_Click(object sender, EventArgs e)
        {
            
        }

        private void frmGiaoDienChinh_Load(object sender, EventArgs e)
        {

        }        
     
    }
}
